package com.wu.cloud.userservice.configuration;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;

/**
 * @author xwu36
 */
public class MyUserDetails implements UserDetails, Serializable {

    private static final long serialVersionUID = -6743567631108323096L;

    private String usernames;

    private String password;

    private boolean isEnable;

    private Collection<? extends GrantedAuthority> roleList;

    public Collection<? extends GrantedAuthority> getRoleList() {
        return roleList;
    }

    public void setRoleList(Collection<? extends GrantedAuthority> roleList) {
        this.roleList = roleList;
    }

    public void setUsername(String username) {
        this.usernames = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public boolean isEnable() {
        return isEnable;
    }

    public void setEnable(boolean enable) {
        isEnable = enable;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return roleList;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return usernames;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return isEnable;
    }
}
